<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes"/>
  <xsl:param name="schemaruntime"/>
  <xsl:param name="schemafile"/>

  <xsl:template match="/">
    <SchemaResponse>
      <SchemaResponseInfo>
        <SchemaFile>
          <xsl:value-of select="$schemafile"/>
        </SchemaFile>
        <ElapsedTime>
          <xsl:value-of select="$schemaruntime"/>
        </ElapsedTime>
      </SchemaResponseInfo>
      <SchemaResults>
        <TransResult>
          <xsl:choose>
            <xsl:when test="count(//ValidationEvent)=0">
              <ResultCode tc="1">Success</ResultCode>
              </xsl:when>
            <xsl:otherwise>
              <ResultCode tc="5">Failure</ResultCode>
            </xsl:otherwise>
          </xsl:choose>
          <ResultInfo>
            <ResultInfoDesc>Schema Validation Execution Result</ResultInfoDesc>
          </ResultInfo>
        </TransResult>
        <xsl:for-each select="//ValidationEvent">
          <ValidationEvent>
            <xsl:attribute name="id">
              <xsl:value-of select="position()"/>
            </xsl:attribute>
            <TransResult>
              <ResultCode tc="5">Failure</ResultCode>
              <ResultInfo>
                <ResultInfoDesc>
                  <xsl:value-of select="./Message"/>
                </ResultInfoDesc>
                <ResultInfoSource>
                  <xsl:value-of select="./Source"/>
                  </ResultInfoSource>
              </ResultInfo>
            </TransResult>
          </ValidationEvent>
          
        </xsl:for-each>
      </SchemaResults>
    </SchemaResponse>
  </xsl:template>
</xsl:stylesheet>